// pages/tourismgonglue/tourismgonglue.js
var app = getApp();
var isPullDown = false;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    picUrl: 'https://p3.pstatp.com/large/43700001e49d85d3ab52',
    isHiddenMes1: true,
    pageIndex: 1,
    rows: 10,
    loadingText: '加载中...', //
    list: [],
    moreData: true, //是否有更多数据


    searValue:'',
    serchType: {
      text: 'none',
      content: '',
      placehould: '输入内容'
    },
    note:[
      {
        name:'旅游1',
        video:'https://ugcbsy.qq.com/uwMRJfz-r5jAYaQXGdGnC2_ppdhgmrDlPaRvaV7F2Ic/w0616b3qe8c.p712.1.mp4?sdtfrom=v1010&guid=321eeebba8831a86062a96228b1d1550&vkey=7AE80E2886C999AD05BC98A6EC507E34CDFA47D59A2E806A208C2FEA3A7A2A7961E2D55822DE1F15C4D0CF2272948AB8C714A3F7371A15947839AACE364E995272ADD91C8F551332E1AE1E8A67AB4D8832F91A60BA43DC931B7D1C56E898928C29595ED2606368AA96F6F2AB13C18F7FEA57E01DCA42F732'
      },
      {
        name: '旅游2',
        video: 'https://apd-c44551d463c7a4c0766b761c9a08e166.v.smtcdns.com/vhot2.qqvideo.tc.qq.com/ARwyjeatBonPgcSf7MdtnGt0jWGcNtIWBzDnhsILJzCU/p0549kupfbx.p712.1.mp4?sdtfrom=v1010&guid=321eeebba8831a86062a96228b1d1550&vkey=A50B6E0457200BCA5F7A49E9602247DAE146C92689508867BF162AB64075EED5E63E7925381B0A4303107062FDBDE4EF9B6C5DDCBAD3EF0BA302F3F7178A0CD56B577FEAEE4BEDE1E0211309C2FED6195FA89C303355AAE910E6912F9423BB6F25374BB668B1E37CB6B4378DF114EF5ED45BCFD29CA1C0C5'
      },
      {
        name: '旅游3',
        video: 'https://apd-fec3435b8e24a9f3815c886baf4b7682.v.smtcdns.com/vhot2.qqvideo.tc.qq.com/A3ug6cKXRdDg_TXXKJ0aVAptuggOHNYckj_MLGOs1v4o/i0790ok6gue.p712.1.mp4?sdtfrom=v1010&guid=321eeebba8831a86062a96228b1d1550&vkey=D9102E5E226451F099B9A183D2E482BDD0F2A6FBB7D8FF84341A4A4C4D1D4BCB437334032F64CB8ADA3CE55505289E0346BB4C5B8E75C6FCAC0D9A09A52EB510CA26EB4CC0769121F11748CE1BE6F368036AEDF38A0375C01F3F9DEEBB1D8B7F8C9F39F8D79D20DF39CDA501F748DD2EB7AF9B9B5D9A67DB'     
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    // this.getStrategys();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {
    this.setData({
      pageIndex: 1, // 每次触发下拉事件page=0
    })
    //发起请求
    isPullDown = true;
    this.getStrategys();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    // 上拉获取更多数据
    if (this.data.moreData) {
      this.getStrategys();
    }
  },
  getStrategys: function() {
    app.apiGet(app.apiList.strategy, {
      pageIndex: this.data.pageIndex,
      rows: this.data.rows
    }, (res) => {
      // 请求成功关闭下拉刷新状态
      if (isPullDown) {
        wx.stopPullDownRefresh();
      }

      if (this.data.pageIndex === 1) {
        let isHiddenMes1 = res.data.length > 0 ? false : true;
        this.setData({
          list: res.data,
          isHiddenMes1: isHiddenMes1,
          pageIndex: this.data.pageIndex + 1
        })
      } else {
        let newList = this.data.list.concat(res.data);
        this.setData({
          list: newList,
          pageIndex: this.data.pageIndex + 1
        })
      }
      // 无更多数据 上拉不再请求数据
      if (res.data.length < this.data.rows) {
        this.setData({
          moreData: false
        })
      }
    })
  },
  orderDetail: function(e) {
    wx.navigateTo({
      url: `../scenedetail/scenedetail?id=${e.currentTarget.dataset.id}`,
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})